import java.sql.*;
import java.util.Properties;

public class Test {
    static Connection connection;
    static Connection connectionT;
//    public static void main(String args[]) throws Exception{
//        getConn();
//        //while (id.next()){
//            String sql="update coop.fuckndzd set amount_average_percent=?, where stu_id='03131015'";
//            com.mysql.jdbc.PreparedStatement pstmt;
//            pstmt = (com.mysql.jdbc.PreparedStatement) connection.prepareStatement(sql);
//            pstmt.executeUpdate();
//            pstmt.close();
//        //}
//    }
    public static void main(String args[]){
        try {
            getConn(1);
            getConn(0);
//            getAllId("04163086");
//            while (IdSet.next()){
//                for(int i=1;i<=8;i++){
//                    MySet.print(IdSet.getString(i)+" ");
//                }
//                MySet.print("\n");
//            }
//            getAId("1725131030");
            getAId("1825121006");
            while (IdSet.next()){
                for(int i=1;i<=44;i++){
                    MySet.print(IdSet.getString(i)+" ");
                }
                MySet.print("\n");
            }
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
    static ResultSet IdSet;
    private static void getAId(String idA) {
        try {
            String sql = "SELECT *  from user_view.fuckndzd_test2 where stu_id='"+idA+"'";
            PreparedStatement PSN = connection.prepareStatement(sql);
            IdSet = PSN.executeQuery();
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
    }
    private static void getAllId(String idA) {
        try {
            String sql = "SELECT *  from ecard_hqu_sends.transaction where XGH='"+idA+"'";
            PreparedStatement PSN = connection.prepareStatement(sql);
            IdSet = PSN.executeQuery();
        }
        catch (SQLException e) {
            e.printStackTrace();
        }
    }
    private static void getConn(int i) throws Exception{
        String driver = "com.mysql.jdbc.Driver";
        //String url = "jdbc:mysql://10.20.21.81:3333/ecard?useSSL=false";
        String url;
        if(i==0) {
            url = "jdbc:mysql://sends-2020-ecard.mysql.polardb.rds.aliyuncs.com:3306/ecard_hqu_sends?useSSL=false";
        }
        else url= "jdbc:mysql://sends-2020-ecard.mysql.polardb.rds.aliyuncs.com:3306/user_view?useSSL=false";
        Properties props = new Properties();
        props.put("user", "ecard_sends");
        props.put("password", "V^MwuJV@gGv^@R%egjry9vrf$bIzVA28");

        Class.forName(driver);
        //connection = DriverManager.getConnection(url,"ecard","CuOlRFMu4avdJknDHIbY");
        if(i==0)
            connection=DriverManager.getConnection(url,props);
        else connectionT=DriverManager.getConnection(url,props);

    }
    static void getConn(){
        String driver = "com.mysql.jdbc.Driver";
        String url = "jdbc:mysql://localhost:3306/coop?useSSL=false";
        try {
            Class.forName(driver);
            connection = DriverManager.getConnection(url,"root","root");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
